Im making a feature that would let you slap a model and make it produce double money. It will do this by duplicating a script and enabling it before the script eventually deletes itself and you have to do it again. My issue is I can find what the players touching. Any help would be great.
Code and errors
local script inside starter character scripts
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local SLAP = Instance.new("Animation")
SLAP.AnimationId = "rbxassetid://9231471239"
local SAT = Animator:LoadAnimation(SLAP)
local function onTouch(hit)
print(hit.Name) -- do whatever u want here
end
local connection
local function AnimPlay(player)
SAT:Play()
humanoid.WalkSpeed = 0
connection = character.RightHand.Touched:Connect(onTouch) -- assigns the variable to the event
wait(1)
humanoid.WalkSpeed = 18
connection:Disconnect() -- stops the event from running
end