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

ROBLOX Wiki Filtering Enabled not working?

Asked by 8 years ago

This is some script from the RemoteFunction and RemoteEvent tutorial on the wiki. I've followed all the instructions however it's still not working. I dont believe I'm missing anything... Please help

-- Inside Local Script
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = game.Workspace.ColorBrick
clickDetector.MouseClick:connect(function(hit)
    game.Workspace.MyServerEvent:FireServer()
end)
-- Inside Server Script
local event = Instance.new("RemoteEvent") -- creates the event object
event.Parent = game.Workspace -- puts the event into the Workspace
event.Name = "MyServerEvent" -- giving a name to the event so we can fire it specifically elsewhere
event.OnServerEvent:connect(function() -- define the function that will be called when the event is fired
        -- this is where you put all the code you want to run when the event is fired
    game.Workspace.ColorBrick.BrickColor = BrickColor.Random() 
end)
0
Looks fine to me. Where is the Local Script located? User#11440 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Make sure the LocalScript is located somewhere in the player Character or in the Player object inside game.Players

You can also put the script in a tool. I prefer StarterPlayerScripts, I made the same mistake before, But i mostly solved it using a code:

Simple script that solved most of my problems:


local function scan(x) for i,v in ipairs(x:GetChildren()) do ---------------------------------------------------------------- if v:IsA("ClickDetector") and v.Parent:FindFirstChild("ClickEvent") then v.MouseClick:connect(function() v.Parent.ClickEvent:FireServer() end) end ---------------------------------------------------------------- if next(v:GetChildren()) ~= nil then scan(v) end end end scan(workspace)

And just put a RemoteEvent called "ClickEvent" on the same folder as the ClickDetector, and Change the script to

local clickEvent = script.Parent.ClickEvent
clickEvent.OnServerEvent:connect(doSomething)
0
That's a cool script. Where did you get it? Also, doing this is unnecessary. User#11440 120 — 8y
Ad

Answer this question