This my script , its only work in studio but in game not

local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
char = player.Character
hum = char.Humanoid
Enabled = true
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://01571062379"

uis.InputBegan:Connect(function(i)
	if i.KeyCode == Enum.KeyCode.R then
		local AtcPlay = player.Character.Humanoid:LoadAnimation(animation)
		AtcPlay:Play()
		wait(1)
		local AlreadyTouched = false
		local ball = Instance.new("Part")
		ball.Shape = "Ball"
		ball.Size = Vector3.new(2,3,1)
		ball.CanCollide = false
		ball.Material = "Neon"
		ball.BrickColor = BrickColor.new("Bright Blue")
		ball.Transparency = 0.7
		
		local bv = Instance.new("BodyVelocity", ball)
		bv.Velocity = char.UpperTorso.CFrame.lookVector * 40 or char.Torso.CFrame.lookVector * 40
		bv.MaxForce = Vector3.new(math.huge, math.huge,math.huge)
		ball.CFrame = char.UpperTorso.CFrame * CFrame.new(0,0,-5) or char.Torso.CFrame * CFrame.new(0,0,-5)
		ball.Parent = workspace
		
		ball.Touched:connect(function(hit)
			if hit and hit.Parent.Humanoid then
				hit.Parent.Humanoid:TakeDamage(5)
			end
		end)
	end
end)

4 comments

0

your game is probably FE, you will need to basically have all of this code other than the UserInputService event inside of a script not a local script, http://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events http://wiki.roblox.com/index.php?title=Converting_Experimental_Mode_Games

0

How do you do that (I'm new to programming)

0

when testing, there is no such thing as clients and servers, till you play it ingame, IS THIS SCRIPT A LocalScript

0

Vulkarin that is true whether the game has FE or not. Server scripts don't deal with LocalPlayers. FE only changes replication a different thing.