Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make this script not kill the player?

I am making a flash like script so when you press F it tpes the player to the direction of the mouse

script():

local Flash = Instance.new("RemoteEvent")
Flash.Name = "FlashService"
Flash.Parent = game.ReplicatedStorage

local function FlashAtEm(plr)
local mouse = plr:GetMouse()
local Char = plr.Character
local Hooman = Char.Humanoid
Char.UpperTorso.Position = mouse.Hit.p
end
Flash.OnServerEvent:Connect(FlashAtEm)

localscript():

local UIS = game:GetService("UserInputService")
local Remote = game.ReplicatedStorage:FindFirstChild("FlashService")
UIS.InputBegan:Connect(function(input)
 if input.KeyCode == Enum.KeyCode.F then
  	Remote:FireServer()
 end
end)

4 comments

0

Moving the torso kills the player instantly, try using another body part or the entire player model.

0

It says Position, CFrame aren't a valid member of Model

0

Use :SetPrimaryPartCFrame() instead to move completely player model.

0

Here, I'll write an example

1 answer

✓ Accepted answer

Just change the "Normal" Script not Local.

al Flash = Instance.new("RemoteEvent")
Flash.Name = "FlashService"
Flash.Parent = game.ReplicatedStorage

local function FlashAtEm(plr)
local mouse = plr:GetMouse()
local Char = plr.Character
local Hooman = Char.Humanoid
Char:SetPrimaryPartCFrame(CFrame.new(mouse.Hit.p))
end
Flash.OnServerEvent:Connect(FlashAtEm)

-- Hope this works

3 comments

0

Thanks!

0

You're welcome and good luck with ur games!

0

This will not work. The Mouse cannot be obtained by the server.

This discussion is preserved as it was. New answers, comments, and votes are closed.