#How to get the character from the player who clicked a ui button
77 messages · Page 1 of 1 (latest)
ReplicatedStorage.Events.ScriptEvents.OffDuty
this organization is pretty wack as well btw
I'm just trying something out, gonna recode the entire game when I'm done
How would I do this tho
plr.Character
OH
OHHHH
no wonder
button.MouseButton1Up:Connect(function(plr)
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(plr)
it cannot be the only way oyu know off cause that should not even work
Yes
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(plr)
remote event
I'm trying to change a certain textlabel whenever the client presses a button
if that makes sense
okay
as you can see Darren
MouseButton1Up
does not passes the player
it passes the x, y vectors of where you let the mouse go
you are in a local script
you have readilly access to the player
Yeah but I need it for in the event
button.MouseButton1Up:Connect(function(plr)
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(plr)
local Character = plr.Character or plr.CharacterAdded:Wait()
the reason this does not error is simply because you shadowed the plr argument
whith the remote event one
else it would be screaming to you that you fucked up
Darren, you already have the player readily available in a local script
it's a local script 😅
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local button = script.Parent
if player:GetRankInGroup(5343537) >= 4 then
button.Parent = script.Parent.Parent.Parent.MainFrame.SettingsFrame
end
button.MouseButton1Up:Connect(function()
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
Character:WaitForChild("Head").Rank.TextLabel.Text = "Off Duty"
end)
end)
so this should work
button.MouseButton1Up:Connect(function()
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
Character:WaitForChild("Head").Rank.TextLabel.Text = "Off Duty"
end)
end)
but why this?
and where are you firing this
ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(player)
In the same script the text im trying to change is originally made in
I don't think that makes sense
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local gui = script.Rank
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
local groupId = plr:GetRoleInGroup(5343537)
local kleur = plr.TeamColor
local team = plr.Team
local guic = gui:clone()
wait() guic.Parent = game.Workspace[plr.Name].Head
guic.Enabled = true
local naam = guic.Name1
local rank = guic.TextLabel
naam.Text = plr.Name
naam.TextColor3 = Color3.new(1,1,1)
rank.TextColor3 = Color3.new(1,1,1)
rank.FontSize = Enum.FontSize.Size14
rank.Text = groupId if not plr:IsInGroup(5343537) then rank.Text = "Guest" end
ReplicatedStorage.Events.ScriptEvents.OffDuty:FireClient(plr)
end)
end)
wtf?
this is a script?
Yes
or a local script
its in serverscriptservice
this is beyond cursed
its that bad?
absolutely horrible
but it works
your organization makes zero sense
yeah i rushed this script
oh yeah that's why you are here, and not developing your game 
because it works, totally
btw, that event you are connecting to
will always be connected to
ty