Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

FireServer is not a valid member of RemoteEvent?

Asked by 6 years ago

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.

01--script
02local famas = game.ServerStorage.FAMAS
03local scarL = game.ServerStorage["SCAR-L"]
04local famasClone = famas:Clone()
05local scarLClone = scarL:Clone()
06local remote = Instance.new("RemoteEvent")
07remote.Parent = game.ReplicatedStorage
08remote.Name = "WeaponEvent"
09 
10remote.OnServerEvent:Connect(function(plr)
11    if famasClone.Parent ~= plr.Backpack then
12        famasClone.Parent = plr.Backpack
13    end
14    if scarLClone.Parent ~= plr.Backpack then
15        scarLClone.Parent = plr.Backpack
16    end
17end)
1--local scriipt
2local weaponRemote = game.ReplicatedStorage:WaitForChild("WeaponEvent")
3 
4button.MouseButton1Click:connect(function()
5    weaponRemote:FireSever()
6end)
0
First of all use :Connect(), second of all I suggest using "UserInputService", unless this is in a gui. LoganboyInCO 150 — 6y
0
If I answered your question, don't forget to hit that "Accept Answer" button! User#24403 69 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

01--script
02local famas = game.ServerStorage.FAMAS
03local scarL = game.ServerStorage["SCAR-L"]
04local famasClone = famas:Clone()
05local scarLClone = scarL:Clone()
06local remote = Instance.new("RemoteEvent")
07remote.Parent = game.ReplicatedStorage
08remote.Name = "WeaponEvent"
09 
10remote.OnServerEvent:Connect(function(plr)
11    if famasClone.Parent ~= plr.Backpack then
12        famasClone.Parent = plr.Backpack
13    end
14    if scarLClone.Parent ~= plr.Backpack then
15        scarLClone.Parent = plr.Backpack
16    end
17end)

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.

1remote.OnServerEvent:Connect(function(client) -- use a better parameter than plr. player is better too
2    if not client.Backpack:FindFirstChild("FAMAS") and not client.Character:FindFirstChild("FAMAS") then
3        famas:Clone().Parent = client.Backpack
4    end
5 
6    if not client.Backpack:FindFirstChild("SCAR-L") and not client.Character:FindFirstChild("SCAR-L") then
7        scarL:Clone().Parent = client.Backpack
8    end
9end)

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.

0
Well this is embarassing RealCoolGuysworld 3 — 6y
0
But thanks alot RealCoolGuysworld 3 — 6y
Ad

Answer this question