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

How would you convert something like this over when using the new client filtering? [closed]

Asked by 10 years ago

For example, say I had something like this:

mouse=Game.Players.LocalPlayer:GetMouse();
mouse.KeyDown:connect(function(key)
if key:lower()=='e' then
Instance.new("Explosion",mouse.Target)
end
end)
--Please note that I'm not actually using the above code for anything, it's just an example.

The new filtering doesn't allow of using Instance.new() in a LocalScript from what I know about it, so how would I go about doing something like this?

Locked by Thewsomeguy, adark, and Articulating

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
3
Answered by
jobro13 980 Moderation Voter
10 years ago

You need to use RemoteFunctions - these ARE allowed to be used with FilteringEnabled.

This goes on the server script:

local RemoteFunction = Instance.new("RemoteFunction")
RemoteFunction.Name = "CreateExplosion"
RemoteFunction.Parent = game.ReplicatedStorage
function RemoteFunction.OnServerInvoke(Position)
local new = Instance.new("Explosion", game.Workspace)
new.Position = Position -- note: explosions have a position property, putting them in a random part just creates an explosion on (0,0,0)
end

This in the client:

function CreateExplosion(pos)
game.ReplicatedStorage.CreateExplosion:InvokeServer(pos or Vector3.new(0,0,0)) 
end

mouse=Game.Players.LocalPlayer:GetMouse();
mouse.KeyDown:connect(function(key)
if key:lower()=='e' then
CreateExplosion(mouse.hit.p)
end
end)
Ad
Log in to vote
-2
Answered by 10 years ago

01 function CreateExplosion(pos) 02 game.ReplicatedStorage.CreateExplosion:InvokeServer(pos or Vector3.new(0,0,0)) 03 end 04

05 mouse=Game.Players.LocalPlayer:GetMouse(); 06 mouse.KeyDown:connect(function(key) 07 if key:lower()=='e' then 08 CreateExplosion(mouse.hit.p) 09 end 10 end)