#How to get the character from the player who clicked a ui button

77 messages · Page 1 of 1 (latest)

untold cliff
#

? you already have access to the character mate 😅

#

ReplicatedStorage.Events.ScriptEvents.OffDuty
this organization is pretty wack as well btw

hoary lake
#

I'm just trying something out, gonna recode the entire game when I'm done

hoary lake
untold cliff
#

OH

#

OHHHH

#

no wonder

#
button.MouseButton1Up:Connect(function(plr)
    ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(plr)
hoary lake
#

cuz uhhh

#

Its the only way I know of

#

OH SHIT

untold cliff
#

it cannot be the only way oyu know off cause that should not even work

hoary lake
#

I HAVE IT TWICE SO IT'LL

#

NOOOOO

untold cliff
#

button.MouseButton1Up:Connect(function(plr)

#

^ that's a button event

hoary lake
#

Yes

untold cliff
#
    ReplicatedStorage.Events.ScriptEvents.OffDuty.OnClientEvent:Connect(function(plr)
#

remote event

hoary lake
#

wait but i need the plr to be in there as it's a client event

#

I am beyond confused

untold cliff
#

me too 🤔

#

wtf are you even doing here?

hoary lake
#

I'm trying to change a certain textlabel whenever the client presses a button

#

if that makes sense

untold cliff
#

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

hoary lake
#

Yeah but I need it for in the event

untold cliff
#
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

untold cliff
#

it's a local script 😅

hoary lake
#
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

untold cliff
#
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)
hoary lake
hoary lake
#

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)
untold cliff
#

wtf?

hoary lake
#

Yes

untold cliff
#

or a local script

hoary lake
#

i made the ui in there

#

a script

untold cliff
#

w t f

#

okay... Ima leave it here

hoary lake
#

its in serverscriptservice

untold cliff
#

this is beyond cursed

hoary lake
#

its that bad?

untold cliff
#

absolutely horrible

hoary lake
#

but it works

untold cliff
#

your organization makes zero sense

hoary lake
#

yeah i rushed this script

untold cliff
#

because it works, totally

hoary lake
#

well the ui itself works

untold cliff
#

will always be connected to

hoary lake
#

yeh still

#

trying to find

#

a other way to do it

#

cuz its in the wrong spot rn

untold cliff
#

everything is, really.

#

anyhow, hope you can get help with it

hoary lake
#

ty