Hi there, i’m pretty new to scripting and the mistake might be obvious but i’m unsure on what i need to change fix this,
The issue is bascailly when a Player clicks the Values/ “Equipped” text changes for all Players instead of the local player.
Local Script:
local player = game:GetService(“Players”).LocalPlayer
local RS = game:GetService(“ReplicatedStorage”)
local gui = script.Parent
– Items
local function UpdateKillEffect()
local Killeffects = player:WaitForChild(“KillEffects”)
for i, Button in pairs(gui.KillEffectScroll:GetChildren()) do
if Button:IsA(“ImageButton”) then
if Killeffects:FindFirstChild(Button.Name) then
Button.EquipStatus.Text = “Owned”
end
if player.EquippedKillEffect.Value == Button.Name then
Button.EquipStatus.Text = “Equipped”
end
if not Killeffects:FindFirstChild(Button.Name) then
Button.EquipStatus.Text = “Buy”
end
end
end
end
UpdateKillEffect()
player:WaitForChild(“EquippedKillEffect”):GetPropertyChangedSignal(“Value”):Connect(function()
UpdateKillEffect()
end)
for i, Button in pairs(gui.KillEffectScroll:GetChildren()) do
if Button:IsA(“ImageButton”) then
Button.Activated:Connect(function() print(Button.Name)
RS.Remotes.EquippedKillEffect:FireServer(“KillEffects”, Button.Name,Button.Price)
end)
end
end
RS.Remotes.Equip.OnClientEvent:Connect(function()
script.Sounds.Equip:Play()
end)
RS.Remotes.Bought.OnClientEvent:Connect(function()
script.Sounds.Buy:Play()
end)
RS.Remotes.Error.OnClientEvent:Connect(function()
script.Sounds.Error:Play()
end)
Server Script:
local RS = game:GetService(‘ReplicatedStorage’)
game:GetService(“Players”).PlayerAdded:Connect(function(Player)
local currentcoins = Player:WaitForChild(“coinstats”).Coins
local storage = RS.KillEffects
local EquippedKillEffect = Instance.new(“StringValue”)
EquippedKillEffect.Parent = Player
EquippedKillEffect.Name = “EquippedKillEffect”
EquippedKillEffect.Value = “None”
RS.Remotes.EquippedKillEffect.OnServerEvent:Connect(function(player, Type, Name, Price) print(“Fired Server”)
if not Name then return end
if not Type then return end
if type(Name) ~= ‘string’ then return end
if Type == “KillEffects” then
if player.KillEffects:FindFirstChild(Name) then
EquippedKillEffect.Value = (Name)
RS.Remotes.Equip:FireClient(player)
return
elseif not Player.KillEffects:FindFirstChild(Name) then
if currentcoins.Value >= Price.Value then
currentcoins.Value = currentcoins.Value - Price.Value
local newkilleffect = Instance.new(“BoolValue”)
newkilleffect.Name = (Name)
newkilleffect.Parent = player.KillEffects
RS.Remotes.Bought:FireClient(player)
return
elseif currentcoins.Value < Price.Value then
RS.Remotes.Error:FireClient(player)
end
end
end
end)
end)
Thanks,
