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 5 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.

--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)
0
First of all use :Connect(), second of all I suggest using "UserInputService", unless this is in a gui. LoganboyInCO 150 — 5y
0
If I answered your question, don't forget to hit that "Accept Answer" button! User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

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

Answer this question