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

Why Is my forcefield GUI not placing forcefield on the player?

Asked by 3 years ago

Ello fellow robloxains! I have appear to come Into a problem when making a GUI as the name suggest Its a simple GUI button that makes a forcefield when you press It however It doesn't spawn on the player rather Instead In the middle of the baseplate how can I overcome this problem?

Script:

1local plr = game.Players.LocalPlayer
2script.Parent.MouseButton1Down:Connect(function()
3    local Forcefield = Instance.new("ForceField")
4    Forcefield.Parent = game.Workspace
5    Forcefield.Position = plr.Character.HumanoidRootPart.Position
6end)

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

what i did to create the forcefield i just used instance.new in a clicked button fuction which i moved the mousebutton1click to the bottom

1local player = game.Players.LocalPlayer
2local character = player.Character
3function ClickedButton()
4    Instance.new("ForceField", character)
5end
6script.Parent.MouseButton1Click:connect(ClickedButton)

Chears!

Ad
Log in to vote
0
Answered by 3 years ago

You can't create a forcefield on the client (assuming this is a client script) since it will only show on the client with FilteringEnabled. Try using a Remote Event so it will run on the server.

Answer this question