Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i make it access the local player?

local plr = game:GetService("Players").LocalPlayer

debounce = false

script.Parent.MouseButton1Click:Connect(function()

if not debounce then

debounce = true

game.Workspace.Part.Value.Value = game.Workspace.Part.Value.Value - 25

wait(1)

debounce = false

end

if game.Workspace.Part.Value.Value == 0 then

game.Workspace.Part.Transparency = 1

plr.PlayerGui.ScreenGui.TextButton.Parent = game.Workspace.Part-- it wont find the local player

wait(5)

game.Workspace.Part.Transparency = 0

game.Workspace.Part.Value.Value = 100

print(script:GetFullName())

end

end)

5 comments

0

I'm assuming this is a local script?

0

Also, you can instead clone the TextButton into the part and destroy the original TextButton.

0

try the "for i,v pairs" method, that's what I use

0
  1. its a normal script 2. i can try that clone method 3. i dont understand the i,v pairs method yet still trying to learn it
0

but i still need to access the local player, thats my issue

1 answer

You can't use the LocalPlayer in a (Server)Script, only LocalScripts.

And, looking at script.Parent.MouseButton1Click:Connect(function(), you seem to be using this in a GUI. If that is true, you'll have to use a localscript as (server)scripts don't work in GUIs. If the problem is FilteringEnabled being forced, you can use remotes.

2 comments

0

thanks

0

@Gameplayer365247v2 Please mark the answer as accepted/correct.

This discussion is preserved as it was. New answers, comments, and votes are closed.