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 6 years ago
01local plr = game:GetService("Players").LocalPlayer
02 
03debounce = false
04 
05script.Parent.MouseButton1Click:Connect(function()
06 
07if not debounce then
08 
09debounce = true
10 
11game.Workspace.Part.Value.Value = game.Workspace.Part.Value.Value - 25
12 
13wait(1)
14 
15debounce = false
16 
17end
18 
19if game.Workspace.Part.Value.Value == 0 then
20 
21game.Workspace.Part.Transparency = 1
22 
23plr.PlayerGui.ScreenGui.TextButton.Parent = game.Workspace.Part-- it wont find the local player
24 
25wait(5)
26 
27game.Workspace.Part.Transparency = 0
28 
29game.Workspace.Part.Value.Value = 100
30 
31print(script:GetFullName())
32 
33end
34 
35end)
0
I'm assuming this is a local script? DeceptiveCaster 3761 — 6y
0
Also, you can instead clone the TextButton into the part and destroy the original TextButton. DeceptiveCaster 3761 — 6y
0
try the "for i,v pairs" method, that's what I use AAzterr 27 — 6y
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 — 6y
0
but i still need to access the local player, thats my issue Gameplayer365247v2 1055 — 6y

1 answer

Log in to vote
0
Answered by 6 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 — 6y
0
@Gameplayer365247v2 Please mark the answer as accepted/correct. RazerGamingKeyboard 17 — 6y
Ad

Answer this question