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

FireServer is not a valid member of RemoteEvent?

I'm making an fps game and when I tried to make a give player item script but it gave this FireServer is not a valid member of RemoteEvent.

--script
local famas = game.ServerStorage.FAMAS
local scarL = game.ServerStorage["SCAR-L"]
local famasClone = famas:Clone()
local scarLClone = scarL:Clone()
local remote = Instance.new("RemoteEvent")
remote.Parent = game.ReplicatedStorage
remote.Name = "WeaponEvent"

remote.OnServerEvent:Connect(function(plr)
	if famasClone.Parent ~= plr.Backpack then
		famasClone.Parent = plr.Backpack
	end
	if scarLClone.Parent ~= plr.Backpack then
		scarLClone.Parent = plr.Backpack
	end
end)

--local scriipt
local weaponRemote = game.ReplicatedStorage:WaitForChild("WeaponEvent")

button.MouseButton1Click:connect(function()
	weaponRemote:FireSever()
end)

2 comments

0

First of all use :Connect(), second of all I suggest using "UserInputService", unless this is in a gui.

0

If I answered your question, don't forget to hit that "Accept Answer" button!

1 answer

✓ Accepted answer

You misspelt FireServer as FireSever. There is still an issue with your script.

--script
local famas = game.ServerStorage.FAMAS
local scarL = game.ServerStorage["SCAR-L"]
local famasClone = famas:Clone()
local scarLClone = scarL:Clone()
local remote = Instance.new("RemoteEvent")
remote.Parent = game.ReplicatedStorage
remote.Name = "WeaponEvent"

remote.OnServerEvent:Connect(function(plr)
    if famasClone.Parent ~= plr.Backpack then
        famasClone.Parent = plr.Backpack
    end
    if scarLClone.Parent ~= plr.Backpack then
        scarLClone.Parent = plr.Backpack
    end
end)

This script would only clone once, and say a different player fires the event, the gun will be taken away from whoever has it. If this is the desired behaviour, keep it. If not, you should clone the weapon inside the event listener. Not outside of it.

remote.OnServerEvent:Connect(function(client) -- use a better parameter than plr. player is better too
	if not client.Backpack:FindFirstChild("FAMAS") and not client.Character:FindFirstChild("FAMAS") then
		famas:Clone().Parent = client.Backpack
	end

	if not client.Backpack:FindFirstChild("SCAR-L") and not client.Character:FindFirstChild("SCAR-L") then
		scarL:Clone().Parent = client.Backpack
	end
end)

Notice the additional check on the character. When you equip a tool it is parented to your character. So they can't give themselves as many tools as they want.

2 comments

0

Well this is embarassing

0

But thanks alot

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