Guis not updating

Guis not updating, please help

  1. What do you want to achieve? Keep it simple and clear!
    i wanted when player clicks a button, it will change some Guis.

  2. What is the issue? Include screenshots / videos if possible!
    it didn’t change the Gui when i pressed the button.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    yes, but no results found.

  4. Additional information
    here is the code, both are localscript:
    the button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	
	ReplicatedStorage.WeaponDescriptionEvent.Sword:Fire()

	
end)

the Gui that i wanna change:

local name = script.Parent.SwordName
local desc = script.Parent.SwordDesc
local image = script.Parent.ImageLabel
local replicatedstorage = game:GetService("ReplicatedStorage")
local sword = replicatedstorage.WeaponDescriptionEvent.Sword
--rbxasset://textures/ui/GuiImagePlaceholder.png

local function onsword()
	
	name.Text = "Sword"
	desc.Text = "Just A Regular Sword, Nothing Special About Em'"
	image.Image = "rbxassetid://15682244886"
	
end

all help is appreciated :grin:

3 Likes

Did you call the function?

sword.Event:Connect(onsword)
2 Likes

I think i called it on the button script

1 Like

You have to run the function in the 2nd script not the first one

1 Like

You fired a RemoteEvent on the LocalScript. Now if you want to get the signal to the Script, the Script first has to receive it, so you have to add to your script the part that yoshi wrote here already.

Alright ill try to do it

Hshdusb

1 Like

I used a bindable event, i forgot to tell you

– Create a LocalScript
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = Instance.new(“Tool”)
tool.RequiresHandle = true
tool.Name = “Sword”
tool.RequiresHandle = true
tool.Parent = player.Backpack

– Create a ClickDetector
local clickDetector = Instance.new(“ClickDetector”)
clickDetector.Parent = tool

– Create a function to handle the sword activation
local function onActivated()
print(“Sword activated!”)

-- Add your sword functionality here, such as dealing damage to opponents

end

– Connect the function to the ClickDetector’s MouseClick event
clickDetector.MouseClick:Connect(onActivated)

Clickdetectors while holding a tool don’t work

Promise me I will That would working

May I ask what exactly script.Parent is in your first script and where is the first local script placed?

I already have the sword, just the gui please

– Create a LocalScript
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = Instance.new(“Tool”)
tool.RequiresHandle = true
tool.Name = “Sword”
tool.RequiresHandle = true
tool.Parent = player.Backpack

– Create a ClickDetector
local clickDetector = Instance.new(“ClickDetector”)
clickDetector.Parent = tool

– Create a function to handle the sword activation
local function onActivated()
print(“Sword activated!”)

-- Add your sword functionality here, such as dealing damage to opponents

end

– Connect the function to the ClickDetector’s MouseClick event
clickDetector.MouseClick:Connect(onActivated)

Wait a sec, let me open my computer

– Create a LocalScript
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local tool = Instance.new(“Tool”)
tool.RequiresHandle = true
tool.Name = “Sword”
tool.RequiresHandle = true
tool.Parent = player.Backpack

– Create a ClickDetector
local clickDetector = Instance.new(“ClickDetector”)
clickDetector.Parent = tool

– Set cooldown time in seconds
local cooldownTime = 2
local canAttack = true

– Create a function to handle the sword activation
local function onActivated()
if canAttack then
canAttack = false
print(“Sword activated!”)

    -- Add your sword functionality here, such as dealing damage to opponents

    -- Reset the cooldown after a certain time
    wait(cooldownTime)
    canAttack = true
end

end

– Connect the function to the ClickDetector’s MouseClick event
clickDetector.MouseClick:Connect(onActivated)

Its not about the sword, its the gui

“Add your sword functionality here, such as dealing damage to opponents”, it’s still about just changing some ui elements. I have the feeling that you use AI to help the OP, which is not bad, but this doesn’t really help out. And also because you type like godspeed to write the scripts

I know about that because I am in the program. But i’m thinking something about that let me see how can I fix that

To give a heads up

If the LocalScript is placed under workspace it will not run
If script.Parent is a ClickDetector, you have to use script.Parent.MouseClick

And in general BindableEvents suck and are the most useless way of script communication. So what you can do is combine the two of your script into one Local Script that you want to do:

-- IT DEPENDS ON WHAT BUTTON THIS IS!!!! I am assuming that its a ui button
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local button = --path to button, use waitforchild('s) if something errors

local swordname = script.Parent.SwordName
local sworddesc = script.Parent.SwordDesc
local swordimage = script.Parent.ImageLabel
local replicatedstorage = game:GetService("ReplicatedStorage")
local sword = replicatedstorage.WeaponDescriptionEvent.Sword
--rbxasset://textures/ui/GuiImagePlaceholder.png


local function onsword()
	
	swordname.Text = "Sword"
	sworddesc.Text = "Just A Regular Sword, Nothing Special About Em'"
	swordimage.Image = "rbxassetid://15682244886"
	
end
button.MouseButton1Click:Connect(onsword)

Ol, ill try it in a second

Jshdjdhdj