Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im trying to make a fighting game but the weapons dont work in fe?

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

4 comments

0

Why aren't all these items/scripts/remotes within ReplicatedStorage? Then a RemoteHandler type folder with the respective remote scripts, if needed, in ServerScriptService...

0

First of all, if the screen gui is already going to be added to the player then just place it under starter gui?

0

No.

0

ok... and why not?

1 answer

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)

2 comments

0

thanks for the reply but where do i put the script where this code is supposed to go?

0

The script I posted would be put into a part, that when clicked would give the player the item listed in another folder ref as "Tools"

This discussion is preserved as it was. New answers, comments, and votes are closed.