Hello. Im trying to make a fighting game and i have got gui and everything. When i press the button for the gun in the editor i get it but not in the actual game. There it doesnt work
so i have a screengui with a textbutton in it the textbutton i made a localscript which holds following code:
script.Parent.MouseButton1Click:Connect(function() local plr = game.Players.LocalPlayer local Event = game.ReplicatedStorage.Equipped Event:FireServer("Aug") end)
the screengui is in serverstorgae
in the serverstorage is also my tool called "Aug"
in serverscriptservice i have a normal script with following code:
game.Players.PlayerAdded:Connect(function(plr) local CloneMe = game.ServerStorage.ScreenGui:Clone() CloneMe.Parent = plr.PlayerGui end) ------------------------------------------------------------------------------------------------------------------------------------------------------- game.ReplicatedStorage.Equipped.OnServerEvent:Connect(function(plr,Message) local Weapon = game.ServerStorage:FindFirstChild(Message) Weapon:Clone() Weapon.Parent = plr.Backpack end)
and i have a remoteevent called "Equipped" in replicatedstorage
I would appreciate any help
If it's helpful, here is a similar "giver" script within a block (its not in a GUI, but maybe you can alter it). Remove the Team part if it doesn't apply.
local button = script.Parent local startcolor = button.BrickColor local DB = false local toolfolder = button.Parent["Tool"] local toolstorage = {} for i, tool in pairs(toolfolder:GetChildren()) do table.insert(toolstorage, tool:clone()) end toolfolder:Destroy() local block = button.Parent:FindFirstChild("Block") if block ~= nil then if block:FindFirstChild("NameDisplay") then if block.NameDisplay.TextLabel.Text == "Tools" then if #toolstorage > 0 then block.NameDisplay.TextLabel.Text = toolstorage[1].Name else block.NameDisplay.TextLabel.Text = "" end end end end button.Touched:connect(function(hit) if DB then return end if hit == nil then return end if hit.Parent == nil then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player ~= nil then if player:FindFirstChild("Backpack") then local allow = true if #allow_team > 0 then local teams = game:GetService("Teams"):GetChildren() if #teams > 0 then allow = false for i, team in pairs(teams) do for i, allowedteamname in pairs(allow_team) do if team.Name == allowedteamname then if player.TeamColor == team.TeamColor then allow = true end end end end end end if not allow_duplicates then for i, tool in pairs(toolstorage) do if player.Backpack:FindFirstChild(tool.Name) then allow = false end end end if allow then DB = true button.BrickColor = BrickColor.new("Black") for i, tool in pairs(toolstorage) do local newtool = tool:clone() newtool.Parent = player.Backpack end wait(2) button.BrickColor = startcolor DB = false end end end end)