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

How do i fix my GUI to appear for only the clicker?

Asked by 5 years ago

So, I am trying to make a dialog GUI its supposed to only appear for the player who clicks the torso of the dummy but instead it does it for all players and i cant use local player and, I have tried quite a few things but it doesn't even give me a error if you could help me out then thank you

game.Players.PlayerAdded:Connect(function(plr)
local CommLog = Instance.new("ScreenGui")
local Text = Instance.new("Frame")
local wow = Instance.new("TextLabel")

local function onClicked()
workspace.Dummy.Torso.ClickDetector.MaxActivationDistance = 0
game.Players.name.Character.Humanoid.WalkSpeed = 0
Text.Visible = true
wow.Text = "H"   
wait(0.30)
wow.Text = "Hi"
wait(4)
Text.Visible = false
wow.Text = ""
plr.Character.Humanoid.WalkSpeed = 16
workspace.Dummy.Torso.ClickDetector.MaxActivationDistance = 32
end

  game.Workspace.Dummy.Torso.ClickDetector.MouseClick:connect(onClicked)
end)

0
Use a LocalScript to do the GUI coding. Server shouldn't be doing this for any reason. User#19524 175 — 5y
0
i have tried moving and editing it to a LocalScript it didnt even appear lbp3fans -1 — 5y
0
There are many things wrong with this script. A few things being that it should be in a LocalScript, you didn't parent the ScreenGui, Frame, or TextLabel to anything, you used "name" instead of "Name", and you used "connect" instead of "Connect". Fixing these most likely wouldn't completely fix your problem, but you should fix them to get somewhat closer to a solution. lunatic5 409 — 5y
0
Unfortunately I cannot look into this further right now as I have to leave, but if you haven't solved your problem by the morning I will be happy to try to solve the problem then. lunatic5 409 — 5y
0
@incapaz, he needs a remote event. He needs Client for GUI Handling, and the Server for the MouseClick event stuff. SBlankthorn 329 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

RemoteEvent Time! Make a 2 RemoteEvents in Rep. and name them "Event1" and "Event2" Server Script:

game.Players.PlayerAdded:Connect(function(player)
local Event = game:GetService("ReplicatedStorage").Event
local Event2 = game:GetService("ReplicatedStorage").Event2
game.Workspace.Dummy.Torso.ClickDetector.MouseClick:Connect(function()
game.Workspace.Dummy.Torso.ClickDetector.MaxActivationDistance = 0
Event:FireClient(player)
end)
Event2.OnServerEvent:Connect(function()
game.Workspace.Dummy.Torso.ClickDetector.MaxActivationDistance = 32
end)
end)

Client Script:

game:GetService("ReplicatedStorage").Event.OnClientEvent:Connect(function()
local CommLog = Instance.new("ScreenGui")
CommLog.Name = "CommLog"
CommLog.Parent = game.Players.LocalPlayer.PlayerGui
local Text = Instance.new("Frame", CommLog)
Text.Name = "Text"
Text.Visible = false
local wow = Instance.new("TextLabel", Text)
wow.Name = "wow"


game.Players.LocalPlayer.Humanoid.WalkSpeed = 0
Text.Visible = true
wow.Text = "H"
wait(.3)
wow.Text = "Hi"
wait(4)
Text.Visible = false
wow.Text = ""
game.Players.LocalPlayer.Humanoid.WalkSpeed = 16
game:GetService("ReplicatedStorage").Event2:FireServer()
end
end)

Try this. If it doesn't work or u dont understand, then leave a comment. Im going to bed now.

0
Sorry about me not explaining much, im just tired. If you don't know what I mean by Server and Client, then oof let me explain. the Server Script you paste in a Script in ServerScriptService. The Client Script, you paste in a local script in StarterGui. In this, when I say "Rep". I mean replicated storage. SBlankthorn 329 — 5y
0
LocalPlayer is nil on the server User#19524 175 — 5y
0
lemme fix dat SBlankthorn 329 — 5y
0
there we go :D SBlankthorn 329 — 5y
View all comments (11 more)
0
it gives me a error saying FireClient: player argument must be a player object lbp3fans -1 — 5y
0
ummm @incapaz help SBlankthorn 329 — 5y
0
R u using the updated script? SBlankthorn 329 — 5y
0
It should work tho lolxdd User#19524 175 — 5y
0
ik it should.. SBlankthorn 329 — 5y
0
im dying from me dealing with this gui all day ;-; lbp3fans -1 — 5y
0
I recently edited the script, try the edit. SBlankthorn 329 — 5y
0
Ugh do u have discord? SBlankthorn 329 — 5y
0
yes xd lbp3fans -1 — 5y
0
Name? SBlankthorn 329 — 5y
0
sent SBlankthorn 329 — 5y
Ad

Answer this question