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

Rebellious remote event fires without my consent then refuses to fire afterwards?

As the title goes, i am having real trouble with these remote events. I made a script that when the client clicks a gui button, it should spawn a humanoid ontop of a part. Problem is that it fires without me even clicking the button then returns nil value if i click it.

Local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage.Mobilization --the remote event
     

script.Parent.MouseButton1Click:Connect(remoteEvent:FireServer())

Server sided script:

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local remoteEvent = ReplicatedStorage.Mobilization --the remote event
	local model = game.ReplicatedStorage.Dummy --the humanoid
	local start = workspace.capital.Position --the part
    
    -- Create a new part
    local function Mobilization()
	local clone = model:Clone()	--spawn humanoid
	clone.Parent = game.Workspace --attach humanoid to workspace so its visible
	clone:MoveTo(start) --teleports humanoid to thje part	
    end
	
     
    remoteEvent.OnServerEvent:Connect(Mobilization)

whole script btw

1 answer

Fixed, problem was in local scripts remote event fire function:

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

script.Parent.MouseButton1Click:Connect(function()
	ReplicatedStorage.Mobilization:FireServer()
	end)

i feel dumb

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