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

How can i make it access the local player?

Asked by 5 years ago
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)
0
I'm assuming this is a local script? DeceptiveCaster 3761 — 5y
0
Also, you can instead clone the TextButton into the part and destroy the original TextButton. DeceptiveCaster 3761 — 5y
0
try the "for i,v pairs" method, that's what I use AAzterr 27 — 5y
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 Gameplayer365247v2 1055 — 5y
0
but i still need to access the local player, thats my issue Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
thanks Gameplayer365247v2 1055 — 5y
0
@Gameplayer365247v2 Please mark the answer as accepted/correct. RazerGamingKeyboard 17 — 5y
Ad

Answer this question