I have a script that sets a player’s weapon.
Localscript, set inside of a textbutton
local plr = game.Players.LocalPlayer
local Request = game.ReplicatedStorage:FindFirstChild("changeweapon")
local Players = game:GetService("Players")
script.Parent.MouseButton1Click:Connect(function(plr,weapon,id)
local weapon = 1
local id = 01
Request:FireServer(plr, weapon, id)
end)
The request is fired, and the receiving script can pick it up and it will set the weapon value… but it sets it to Nil, disregarding the weapon value sent to it.
Regular script, Set inside ServerScriptService, reading a RemoteEvent from ReplicatedStorage
local Request = game.ReplicatedStorage:FindFirstChild("changeweapon")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function onrequestFired(plr, weapon, wepid)
warn(plr.Name)
local folder = game.ServerStorage.Statfile:FindFirstChild(plr.Name).statnumbers
folder.Weaponid0.Value = weapon
warn(weapon)
end
Request.OnServerEvent:Connect(onrequestFired)
warn(weapon) returns as nil
How would i go about actually sending the weapon value? Which scripts would i have to change to correct this error?