What the script does is it just spawns a ball shaped projectile from a user. I am trying to make it jump scare a player when they touch the ball. I tried to make a function that actives on touch but nothing is working for me. So how do i make a script that jump scares a player when they touch it.
This script is a local script and it goes into the "StarterPack" and if possible can we not have the script have other scripts in it.
plr = game.Players.LocalPlayer
repeat
wait(0.4)
until plr.Character
chr = plr.Character
human = chr:FindFirstChild("Humanoid")
mouse = plr:GetMouse()
tors = chr.Torso
Speed = 80
function VOID()
voidball = Instance.new("Part",game.workspace)
print("VOID")
--The ball--
voidball.Transparency = 0.5
voidball.CFrame = plr.Character.Torso.CFrame*CFrame.new(0, 0, -12)
voidball.Shape = "Ball"
voidball.BrickColor = BrickColor.new("Really black")
voidball.Size = Vector3.new(5,5,5)
voidball.TopSurface = "Smooth"
voidball.BottomSurface = "Smooth"
--BodyVelocity--
y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
y.velocity = plr.Character.Torso.CFrame.lookVector*Speed
y.Parent = voidball
--ParticleEmitter--
Effects = Instance.new("ParticleEmitter")
Effects.Parent = voidball
Effects.LockedToPart = true
Effects.Speed = NumberRange.new(0)
Effects.Size = NumberSequence.new(2)
Effects.Texture = "rbxassetid://680574921"
Effects.Lifetime = NumberRange.new(0.1)
Effects.Rate = 200
end
function voidscare(hit)
local h = hit.Parent:FindFirstChild("Humanoid") -- I can't make it work
print"BOO" --- I didn't make the jumpscare yet so i used print instead
end
mouse.KeyDown:connect(function(key)
if key == "e" then
VOID()
end
end)

5 comments
mouse.KeyDown is deprecated. Look into UserInputService. http://wiki.roblox.com/index.php?title=API:Class/UserInputService
Are there any errors in the output?
Update: Ok at first there were no errors because i was not calling my function. So i tried to call my function but, i got an error saying that voidball was nil because it wasn't in the game yet. So i put the my call in the on pressed key e function but now i get the error "ck End 17:22:01.250 - Humanoid is not a valid member of Part"
Using Instance.new with the parent parameter, see more here https://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296
Also, READ MY BIO HOW HARD CAN THIS BE?????????