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

How do I make this User InputService script work in the game as well?

Asked by 6 years ago

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)
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 Vulkarin 581 — 6y
0
How do you do that (I'm new to programming) Goodbye_Fx 29 — 6y
0
when testing, there is no such thing as clients and servers, till you play it ingame, IS THIS SCRIPT A LocalScript fanofpixels 718 — 6y
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. cabbler 1942 — 6y

Answer this question