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

Object not spawining on the player help?

Asked by 4 years ago

I'm trying to spawn a box on the player and their surrounding area to slow them and those nearby down.

The problem I'm facing is that the box is spawning just not on the player, instead it's spawning where I had originally created the box

Here's the code, any help would be much appreciated:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local tEBox = game.ReplicatedStorage:WaitForChild("timeEraseBox")
local human = char:WaitForChild("Humanoid")
local userInput = game:GetService('UserInputService')

userInput.InputBegan:Connect(function(key)``
    if key.KeyCode == Enum.KeyCode.F then
        local tEBoxClone = tEBox:Clone()
        tEBoxClone.Parent = game.Workspace
        tEBoxClone.SetPrimaryPartCFrame(target.CFrame)

        script.Parent.Touched:connect(function(hit)
            if hit.Parent.Humanoid then
                _G.isSprinting = false
                human.WalkSpeed = "0"
            end
        end)
    end
end)
0
Any errors. And what is target? Luka_Gaming07 534 — 4y
0
Any errors. And what is target? Luka_Gaming07 534 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

First, is this local script, if not change it in to local now. Second, why you do this human.WalkSpeed = "0", because you can't change the humanoid WalkSpeed by string, it has to be number.

Ad

Answer this question