What are you trying to achieve?.
For the remote event to fire
What is the issue?.
The remote event doesn’t seem to be firing or receiving.
What solutions have you tried so far?
I put some prints in the code. I put a print right before the RE:FireServer(ore, drill, money, button) and the print fired, but the server script doesn’t seem to be detecting that the remote event has fired.
Local script:
local RE = script:WaitForChild("RemoteEvent")
local button = script.Parent
local player = game.Players.LocalPlayer
local money = player.leaderstats:WaitForChild("Money")
local ore = button.Parent.Parent.Parent.Values:WaitForChild("Ore")
button.MouseButton1Click:Connect(function()
if money.Value >= 20 then
local drill = ore.Value.Upgrades.DrillModel1:Clone()
drill.Parent = ore.Value.CurrentUpgrades
print('fef')
RE:FireServer(ore, drill, money, button)
end
end)
Server script:
local RE = script.Parent:WaitForChild("RemoteEvent")
print('fr')
RE.OnServerEvent:Connect(function(ore, drill, money, button)
print('fired')
local upgradeUi = ore.UpgradeUi
ore.Value.Values.ApplianceUpgradeValue.Value = 1
money.Value -= 20
button.Text = "CONFIRMED"
button.TextColor3 = Color3.new(0.180392, 1, 0)
button.Parent.Parent.Parent.Enabled = false
button.Parent.Parent.Visible = false
button:Destroy()
upgradeUi.Enabled = true
upgradeUi.UpgradeFrame:TweenSize(UDim2.new(1,0,0,0),Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 5, true, nil)
upgradeUi.Enabled = false
upgradeUi.Size = UDim2.new(1,0,.5,0)
for i, v in pairs(drill:GetChildren()) do
v.Transparency = 0
v.CanCollide = true
end
end)
It’s usually best to have server scripts in ServerScriptStorage and remotes events in replicated storage. I don’t know but maybe that will fix it. Also, you don’t need waitforchilds in server scripts. Only in localscripts because you need to wait for the things to load in on the client but not the server.
Those variables are all created in the local script and sent to the server when the server is fired correctly, the issue was the “OnServerEvent” not declaring an additional parameter to handle the passed player object.
Oh, and your issue was caused by the fact that you have a server script inside the “StarterGui” folder meaning that it won’t execute, both server scripts and local scripts can only run if they are placed in the correct directories (folders).