when a player in my game clicks a button in a menu in my game it sets a string value on the player to the equipped value of the button i named the value eq like if the player equips the color blue the value will be set to Blue. however its in a local script and only sets it client side. but if i change it to a regular script it dosent work at all and my game script reads the players eq value on the server side to give them the blue weapon.
Script on button:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player.Shop.Red.Value == true then
player.eq.Value = "Red"
end
end)
Code in game script:
for _, player in pairs (game.Players:GetPlayers()) do
if player.eq.Value == "Red" then
local primary = game.ReplicatedStorage.Red
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
if player.eq.Value == "Yellow" then
local primary = game.ReplicatedStorage.Yellow
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
if player.eq.Value == "Blue" then
local primary = game.ReplicatedStorage.Blue
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
if player.eq.Value == "Green" then
local primary = game.ReplicatedStorage.Green
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
if player.eq.Value == "None" then
local primary = game.ReplicatedStorage.Sword
local newprimary = primary:Clone()
newprimary.Parent = player.Backpack
end
end

2 comments
Use remote events. Fire from local
https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events