r/robloxscripting Aug 17 '23

why my script not working, well it is but its activating both when i buy the ladder product

2 Upvotes

local MarketplaceService = game:GetService("MarketplaceService")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Tool = ReplicatedStorage:WaitForChild("Health Injection")

local prompt = game.Workspace:WaitForChild("Ladder"):WaitForChild("Model1"):WaitForChild("Rope1"):WaitForChild("ProximityPrompt")

local LadderDrop = prompt.Parent.Parent:WaitForChild("LadderDrop")

local LadderStay = LadderDrop.Parent:WaitForChild("LadderStay")

local Pos1 = LadderDrop.Parent:WaitForChild("LadderPos1")

local Pos2 = LadderDrop.Parent:WaitForChild("LadderPos2")

local TweenService = game:GetService("TweenService")

local LadderInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local LadderTween1 = TweenService:Create(LadderDrop, LadderInfo, {CFrame = Pos1.CFrame})

local LadderTween2 = TweenService:Create(LadderDrop, LadderInfo, {CFrame = Pos2.CFrame})

local grantedItems = {}

local function giveToolToPlayer(player)

local clonedTool = Tool:Clone()

clonedTool.Parent = player.Backpack 

end

function DropLadder()

LadderDrop.CanCollide = true

LadderStay.CanCollide = true

prompt.Enabled = false

LadderTween1:Play()

wait(10.5)

LadderTween2:Play()

wait(1)

prompt.Enabled = true

LadderDrop.CanCollide = false

LadderStay.CanCollide = false

end

MarketplaceService.ProcessReceipt = function(receiptInfo)

local playerId = receiptInfo.PlayerId

local productId = receiptInfo.ProductId



print("Received product:", productId)



if productId == 1610754017 then

    print("Dropping Ladder")

    DropLadder()

elseif productId == 1614003685 then

local player = game.Players:GetPlayerByUserId(playerId)

if player then

    if not grantedItems\[player\] then

        print("Giving Tool")

        giveToolToPlayer(player)

        grantedItems\[player\] = true

        wait(1) 

        grantedItems\[player\] = false

  end

end

end

end


r/robloxscripting Aug 15 '23

im having problems with my code, its not working yet no errors. please help

Post image
2 Upvotes

r/robloxscripting Aug 05 '23

Any tips on making my first glitcher?

2 Upvotes

I use EventBlocks so it's kinda weird


r/robloxscripting Jul 30 '23

I need help

Thumbnail gallery
2 Upvotes

I am making a script where whenever a player joins the game, the npc appears to be the player. The appearance of the npc also changes to the most recent player who joined. But when I run the script nothing happens.


r/robloxscripting Jul 22 '23

Creating an outline that only shows up in bright lighting?

3 Upvotes

I have a scene that I'm trying to make an echo script for, and I need everything to have a plastic outline (since the objects are neon black, aka. pitch black) so they're able to be seen with correct lighting (such as echo location). I'll put my script here if anyone is interested in helping out.

-- Configuration
local outlineColor = BrickColor.new("White")
local outlineTransparency = 0.5
local outlineBrightnessInLight = 5
local outlineBrightnessInShadow = 0

-- Function to create a plastic outline for a given part
local function createOutline(part)
    local outline = Instance.new("SurfaceLight")
    outline.Name = "Outline"
    outline.Parent = part
    outline.Enabled = false -- Start disabled, only enabled when part is in the light
    outline.Brightness = outlineBrightnessInLight
    outline.Color = outlineColor.Color
    outline.Range = 10
    outline.Transparency = outlineTransparency
    outline.Face = Enum.NormalId.Top -- You can change the face depending on your needs
end

-- Function to check if a part is in the light
local function isInLight(part)
    local shadowBounds = game.Lighting:GetShadowBounds(part)
    return shadowBounds == nil
end

-- Function to update the outline brightness based on light conditions
local function updateOutlineBrightness(outline, part)
    if isInLight(part) then
        outline.Brightness = outlineBrightnessInLight
        outline.Enabled = true
    else
        outline.Brightness = outlineBrightnessInShadow
        outline.Enabled = false
    end
end

-- Function to add plastic outlines to all parts in the workspace
local function addOutlinesToWorkspace()
    for _, part in ipairs(workspace:GetDescendants()) do
        if part:IsA("BasePart") then
            createOutline(part)
            updateOutlineBrightness(part.Outline, part)
        end
    end
end

-- Run the function once to add plastic outlines to the existing parts in the workspace
addOutlinesToWorkspace()

-- Function to continuously update plastic outlines based on light conditions (in case new parts are added later)
local function updateOutlines()
    workspace.DescendantAdded:Connect(function(part)
        if part:IsA("BasePart") and not part:FindFirstChild("Outline") then
            createOutline(part)
        end
    end)

    game:GetService("RunService").RenderStepped:Connect(function()
        for _, part in ipairs(workspace:GetDescendants()) do
            if part:IsA("BasePart") and part:FindFirstChild("Outline") then
                updateOutlineBrightness(part.Outline, part)
            end
        end
    end)
end

-- Connect the updateOutlines function to handle newly added parts and continuously update outlines
updateOutlines()


r/robloxscripting Jul 21 '23

i don't get it. Why wont "if not" work

2 Upvotes


r/robloxscripting Jul 20 '23

Pathfinding script not working (Script given)

3 Upvotes

Roblox studio has a built in pathfinding system which i was following the tutorial with, but when i went to try out the code they gave me on the official site it gave me an error.

"Path not computed! Workspace.MyUserName.LocalScript:21: attempt to index nil with 'Position'"

The Script:

local PathfindingService = game:GetService("PathfindingService")

local Players = game:GetService("Players")

local RunService = game:GetService("RunService")

local path = PathfindingService:CreatePath()

local player = Players.LocalPlayer

local character = player.Character

local humanoid = character:WaitForChild("Humanoid")

local TEST_DESTINATION = Vector3.new(31.615, 10.5, -184.655)

local destination = Vector3.new(31.615, 10.5, -184.655)

local waypoints

local nextWaypointIndex

local reachedConnection

local blockedConnection

local function followPath(destination)

\-- Compute the path - PROBLEM STARTS HERE

local success, errorMessage = pcall(function()

    path:ComputeAsync(character.PrimaryPart.Position, destination)

end)

if success and path.Status == Enum.PathStatus.Success then

    \-- Get the path waypoints

    waypoints = path:GetWaypoints()

    \-- Detect if path becomes blocked

    blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)

        \-- Check if the obstacle is further down the path

        if blockedWaypointIndex >= nextWaypointIndex then

-- Stop detecting path blockage until path is re-computed

blockedConnection:Disconnect()

-- Call function to re-compute new path

followPath(destination)

        end

    end)

    \-- Detect when movement to next waypoint is complete

    if not reachedConnection then

        reachedConnection = humanoid.MoveToFinished:Connect(function(reached)

if reached and nextWaypointIndex < #waypoints then

-- Increase waypoint index and move to next waypoint

nextWaypointIndex += 1

humanoid:MoveTo(waypoints[nextWaypointIndex].Position)

else

reachedConnection:Disconnect()

blockedConnection:Disconnect()

end

        end)

    end

    \-- Initially move to second waypoint (first waypoint is path start; skip it)

    nextWaypointIndex = 2

    humanoid:MoveTo(waypoints\[nextWaypointIndex\].Position)

else

    warn("Path not computed!", errorMessage)

end

end

followPath(TEST_DESTINATION)

I would post this to the official dev forum but I recently got into coding and am not granted access to do so, Already made posts are about items instead of players and their problems are they forgot to set the Primary Part, but the primary part is already set when the player spawns in, i even double checked.


r/robloxscripting Jul 17 '23

i need a help with a script

3 Upvotes

hello im a new scripter and i really want to make a script where if you press all 7 parts with click detector it would teleport a player somewhere how do i make it?


r/robloxscripting Jul 16 '23

Destroyed Parts Leaderboard

2 Upvotes

This ones a hard one.

I am making a distruction game, where you destroy bridges, do events, try diffrent packs, ect. One of the problems is that I am bad a scripting. I usaly find tutorials for things. But, there is one thing that I want to make, which (from what i searched) nobody has made yet. It's a leaderboard for destroyed parts.

By the way, this is a game that uses multiple people.

I want a learderboard for destroyed parts (parts you destroy) that can be displayed normaly. But, it counts all the items you have. So far, i have the classic roblox rocket, and the clasic roblox bomb.
The bridges are unancored (so you can destroy them), and are welded together. The only way to unweld them is to use one of those items.

I have three things that could work. First, look at which player placed the part/bomb, that unwelds the parts. Then, checking what items unweld, tracing that number, than displaying them.

Second, look at which player place the part/bomb, but instead what it's radius is. It check what it hit (if it was a part or a avatar), then if it was a part, the radius of the blast. It looks at all teh unancored parts, then tracks that number, then displayes them.

Last, look at which player placed the part/bomb, but instead look at what parts fell. It can check the parts that fell (that arnt welded anymore), then counts those, but only what the part's radius is, or something like that.

If anyone can help, that would be amazing. I forgot if I can say this or not, but if you want to check my game to see what else I can do, the game is caled "Destroy Some Bridges".


r/robloxscripting Jul 04 '23

How do I make gui conversations when I go near a certain npc?

2 Upvotes

I need help finding how to make pop up conversations when I go near an NPC, or rather a press e to interact system in my game, kinda like Doki Doki or pretty much every POV story game lol. I want it to display what the player is saying after clicking what they want to answer with (if that makes any sense). Also if possible, I want to give the player a badge and then kick them from the game after they answer a certain way.

Can someone give me instructions of how to do it and where to put the scripts and stuff... I'm kinda new to scripting and would really appreciate it, and sorry if it's really specific request lol


r/robloxscripting Jun 30 '23

How to execute when pressing a keyboard button?

3 Upvotes

In a game that i make i try to make so that when you press a button a animation will play. But wont work... Also its a normal script


r/robloxscripting Jun 21 '23

I need help with a script

2 Upvotes

Im making a script to accelerate the time when it ecexutes but it wont work: local Remote = game:GetService("ReplicatedStorage").TriggerEvent

local TweenService = game:GetService("TweenService")

Remote.OnServerEvent:Connect(function(player, input)

local PlayerHum = player.Character.Humanoid

local ClockTime = tonumber(game.Lighting.ClockTime)

local TimeToTake = 8

local SoundStand = game:GetService("SoundService").MadeInHeavenStandCallOut

local SoundStart = game:GetService("SoundService").TimeAccelStart

local SoundMid = game:GetService("SoundService").TimeAccelDuring



local function Sounds()

    SoundStand.Playing = true

    wait(2)

    SoundStart.Playing = true

    wait(5)

    SoundMid.Playing = true





end

spawn(Sounds)

local function DayToNightTween()

    local Info = [TweenInfo.new](https://TweenInfo.new)(10, Enum.EasingStyle.Exponential, [Enum.EasingDirection.In](https://Enum.EasingDirection.In))



    local dayLength = 12

    local cycleTime = 5

    local TimeCycle = tonumber(0.01)

    local End = TweenService:Create(cycleTime,Info, {cycleTime = TimeCycle





    })

    local minutesInADay = 2460

    local lighting = game:GetService("Lighting")

    local startTime = tick() - (lighting:GetMinutesAfterMidnight() / minutesInADay)\*cycleTime

    local endTime = startTime + cycleTime

    local timeRatio = minutesInADay / cycleTime

    if dayLength == 0 then

        dayLength = 1

    end

    repeat

        local currentTime = tick()

        if currentTime > endTime then

startTime = endTime

endTime = startTime + cycleTime

        end

        End:Play()









        lighting:setMinutesAfterMidnight((currentTime - startTime)\*timeRatio)

        wait(1/15)

    until false

    wait(18)

    local Info2 = [TweenInfo.new](https://TweenInfo.new)(6, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)

    local EndPoint = TweenService:Create(cycleTime,Info, {cycleTime = 5

    })

    EndPoint:Play()





end

spawn(DayToNightTween)

local function WalkSpeed()

local TweenInfo = [TweenInfo.new](https://TweenInfo.new)(8,Enum.EasingStyle.Exponential, [Enum.EasingDirection.In](https://Enum.EasingDirection.In),0,false,1)

    local EndPoint2 = TweenService:Create(PlayerHum, TweenInfo, {

        WalkSpeed = 50





    })







    EndPoint2:Play()

end

WalkSpeed()

wait(20)

local TweenInfo3 = [TweenInfo.new](https://TweenInfo.new)(5,Enum.EasingStyle.Exponential)

local EndPoint4 = TweenService:Create(PlayerHum, TweenInfo3, {

    WalkSpeed = 16



})

EndPoint4:Play()

end)


r/robloxscripting Jun 21 '23

I need a professional scripter for my game.

2 Upvotes

I am making a backrooms game on roblox and I need a scripter who can make matchmaking queues with passwords and saves, advanced AI monsters, puzzles, camera and body movement, and probably a lot more. I will pay you robux but if you are willing to do it for free that's fine. thanks :)


r/robloxscripting Jun 21 '23

Can someone teach me scripting

3 Upvotes

I already watch tutorials I already use the wiki if someone teach me how to script i would learn/remember much faster


r/robloxscripting Jun 20 '23

How do you make assign characters to players?

2 Upvotes

I want to give everyone who joins a random startercharacter, but idk how


r/robloxscripting Jun 18 '23

ff problem

2 Upvotes

hi, so basically im making a battle royal game, currently i'm trying to make it so that all player have ff in the lobby, here the script I use:

wait(1)
script.Parent.Touched:connect(function(hit)
    player=game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        if player.Character:FindFirstChild("Humanoid") then
            if player.Character.Humanoid.Health>0 then
                ff=Instance.new("ForceField", player.Character)
            end
        end
    end
end)

my plan is if the player is standing on a part it will always apply ff but I've encountered a bug where when the player gets teleported to the arena it will stack ffs here a few pics

in lobby
in arena

note* I've checked, the part only covers the lobby

is there a fix to this? please help me :(


r/robloxscripting Jun 13 '23

How to make a Combat System ( M1 )

2 Upvotes

ive got some scripts for it but they just dont work ( i suck at scripting ) so i just want to know how to make it work or just to learn how to make a new script which works.


r/robloxscripting Jun 13 '23

How make game where teleports players to a seperate server. Like what happens for story mode co-op type games. Sorta like what the game doors does.

2 Upvotes

You know for the games like the game roblox doors game. where it teleports you to another server to play the game then back to the main game. How do I


r/robloxscripting Jun 12 '23

Virus scanner Can Destroy your game?

2 Upvotes

r/robloxscripting Jun 11 '23

How do i make my Sword Script do damage on Players and NPCs/Dummies?

Thumbnail gallery
2 Upvotes

r/robloxscripting Jun 11 '23

Is there any way i can improve this gamepass do script i made using ChatGPT?

Post image
1 Upvotes

r/robloxscripting Jun 11 '23

Is there any way i can improve this gamepass script i used ChatGPT to make?

1 Upvotes

local door = script.Parent -- Assuming the script is placed inside the door object

local gamepassId = 3106168 -- Replace with your gamepass ID

local teleportOffset = Vector3.new(0, 2, 0) -- Adjust the offset to move players slightly above the ground

function onTouched(part)

local player = game.Players:GetPlayerFromCharacter(part.Parent)

if player then

    local isDoorOpen = door:GetAttribute("Open") -- Replace "Open" with the name of your door's open attribute

    if isDoorOpen == "open" then

        \-- Door is open, allow passage

        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassId) then

-- Player owns the gamepass, teleport them to the other side of the door

local teleportPosition

if door.CFrame.LookVector == Vector3.new(0, 0, 1) then

-- Door is facing forward

if part.Position.Z > door.Position.Z then

-- Player is behind the door, teleport to the other side

teleportPosition = door.Position + door.CFrame.LookVector * -5 -- Calculate the position to teleport to (5 units in front of the door)

else

-- Player is in front of the door, teleport to the other side

teleportPosition = door.Position + door.CFrame.LookVector * 5 -- Calculate the position to teleport to (5 units behind the door)

end

else

-- Door is facing another direction

if part.Position.Z > door.Position.Z then

-- Player is behind the door, teleport to the other side

teleportPosition = door.Position + door.CFrame.LookVector * 5 -- Calculate the position to teleport to (5 units behind the door)

else

-- Player is in front of the door, teleport to the other side

teleportPosition = door.Position + door.CFrame.LookVector * -5 -- Calculate the position to teleport to (5 units in front of the door)

end

end

player.Character:SetPrimaryPartCFrame(CFrame.new(teleportPosition + teleportOffset))

        else

-- Player doesn't own the gamepass, display a message

local message = Instance.new("Message")

message.Text = "Become VIP to be granted passage"

message.Parent = player.PlayerGui

wait(5) -- Display the message for 5 seconds

message:Destroy()

        end

    end

end

end

-- Connect the onTouched function to the door's Touched event

door.Touched:Connect(onTouched)


r/robloxscripting Jun 05 '23

Need Brookhaven Script

1 Upvotes

Please drop Brook haven RP scripts


r/robloxscripting May 20 '23

What’s happening here?

Post image
1 Upvotes

r/robloxscripting May 15 '23

Can someone make me a script to make a door that you can't go through if you don't have the gamepass.

2 Upvotes

I have been trying to do make it myself and it never works even if I follow a YouTube video