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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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

Ad

Answer this question