I use the UserInputService to get E is the key when I press zombie will spawn on my cursor. I don't know what is wrong with my script
01 | local zombie = game.ServerStorage:WaitForChild( "Zombie" ) |
02 |
03 | game.ReplicatedStorage.Zombie.OnServerEvent:Connect( function (player) |
04 |
05 | local mouse = player:GetMouse() |
06 | local character = workspace:WaitForChild(player.Name) |
07 |
08 | wait() |
09 | local a = Instance.new( "Animation" , character) |
10 | a.AnimationId = "rbxassetid://5713765649" |
11 |
12 | local a 1 = character:WaitForChild( "Humanoid" ):LoadAnimation(a) |
13 | a 1 :Play() |
14 |
15 | while true do |
I tried something that I get mouse through client script, but the zombie still does not spawn on mouse hit. I don't have any error either
01 | local zombie = game.ServerStorage:WaitForChild( "Zombie" ) |
02 |
03 | game.ReplicatedStorage.Zombie.OnServerEvent:Connect( function (player,firePosition) |
04 |
05 | local mouse = player:GetMouse() |
06 |
07 | local character = workspace:WaitForChild(player.Name) |
08 |
09 | wait() |
10 | local a = Instance.new( "Animation" , character) |
11 | a.AnimationId = "rbxassetid://5713765649" |
12 |
13 | local a 1 = character:WaitForChild( "Humanoid" ):LoadAnimation(a) |
14 | a 1 :Play() |
15 | local Player = game:GetService( "Players" ).LocalPlayer |
100% Fixed
01 | local zombie = game.ServerStorage:WaitForChild( "Zombie" ) |
02 |
03 | game.ReplicatedStorage.Zombie.OnServerEvent:Connect( function (player,firePosition) |
04 |
05 | local mouse = player:GetMouse() |
06 |
07 | local character = workspace:WaitForChild(player.Name) |
08 |
09 | wait() |
10 | local a = Instance.new( "Animation" , character) |
11 | a.AnimationId = "rbxassetid://5713765649" |
12 |
13 | local a 1 = character:WaitForChild( "Humanoid" ):LoadAnimation(a) |
14 | a 1 :Play() |
15 | local Player = game:GetService( "Players" ).LocalPlayer |