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 11 years ago

For example, say I had something like this:

1mouse=Game.Players.LocalPlayer:GetMouse();
2mouse.KeyDown:connect(function(key)
3if key:lower()=='e' then
4Instance.new("Explosion",mouse.Target)
5end
6end)
7--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
11 years ago

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

This goes on the server script:

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

This in the client:

01function CreateExplosion(pos)
02game.ReplicatedStorage.CreateExplosion:InvokeServer(pos or Vector3.new(0,0,0))
03end
04 
05mouse=Game.Players.LocalPlayer:GetMouse();
06mouse.KeyDown:connect(function(key)
07if key:lower()=='e' then
08CreateExplosion(mouse.hit.p)
09end
10end)
Ad
Log in to vote
-2
Answered by 11 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)