Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Studio is not running my script, however there are no errors in the output?

Asked by 5 years ago

Hello, So I am attempting to create a teleport script to use as an elevator in one of the games I am working on, however my script is not running. It's a localscript in a part to test as a button (regular script was doing the same thing, however giving me an error saying that "player" was a nil value while it was a parameter in onClick) There are no errors in the output, could anyone let me know if there's something I'm doing wrong?

-- elevator trial

local b = script.Parent
local fL = script.Parent.Parent
local f1 = game.Workspace.Elevator.floor1

function onClick(player)
    local p = player.Parent:FindFirstChild("Humanoid")
    if (p ~= nil) then
        p.Parent.Torso.CFrame = f1.CFrame + CFrame.new(Vector3.new(0,3,0))
    end
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)
print("worked! :D") -- just here see if the script was running, i'm getting nothing in the output
0
well, p(the part where you tried to find the humanoid) is nil, because the humanoid isn't located there, it is inside Player.Character, theking48989987 2147 — 5y
0
so would i change it to: local p = player.Character:FindFirstChild("Humanoid") toastre 0 — 5y
0
^ still doesnt work toastre 0 — 5y
0
Edit line 08: local p = player.Character:FindFirstChild("HumanoidRootPart") Voxozor 162 — 5y
View all comments (5 more)
0
^ its his choice User#23365 30 — 5y
0
still not working toastre 0 — 5y
0
Is it a local script? theking48989987 2147 — 5y
0
Try Changing f1 variable to FloorOne and adjust. BlackOrange3343 2676 — 5y
0
add a print inside the if statement (where you set the Torso's CFrame) hellmatic 1523 — 5y

Answer this question