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

i am trying to make a ball it works in stioudo put not in real game how do i fix?

Asked by 5 years ago

here is fire script

local plr = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")

InputService.InputBegan:Connect(function(input)
    local key = input.KeyCode --Gets the key that the player pressed
    if key == Enum.KeyCode.R then --Checks if the key is Q
   game.Workspace.act:FireServer()

    end
end)
local plr = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")

InputService.InputEnded:Connect(function(input)
    local key = input.KeyCode 
    if key == Enum.KeyCode.R then
       game.Workspace.fer:FireServer()
    end
end)

here is the script that wont work the listiner


game.Workspace.fer.OnServerEvent:Connect(function() local we = game.Players.LocalPlayer local plr = game.Players.LocalPlayer.Character local x = plr.Fire local wa = game.Players.LocalPlayer.Character:WaitForChild("Fire") local b = Instance.new("BodyVelocity",wa) local mouse = we:GetMouse() b.MaxForce = Vector3.new(math.huge,math.huge,math.huge) x.Anchored = false b.Velocity = mouse.Hit.LookVector * 34 wa.Parent = workspace end) local fly = true game.Workspace. act.OnServerEvent:Connect(function() local L = game.Players.LocalPlayer local plr = game.Players.LocalPlayer.Character local i = Instance.new("Part",plr) i.Position = plr.UpperTorso.Position i.Anchored = true i.BrickColor = BrickColor.new("Dark blue") i.Shape = "Ball" i.Material = "Neon" i.Name = "Fire" i.CanCollide = false while fly == true do wait(.78) i.Size = i.Size + Vector3.new(.4,.4,4) end end)
0
it wont show up helleric -3 — 5y
2
LocalPlayer doesn't work on a server side script, but the OnServerEvent Event has an argument called player, so to get the player just do "game.Workspace.fer.OnServerEvent:Connect(function(player)" MythicalShade 420 — 5y
1
There's many other problems with your script too, including the space between "Workspace." and "act" on line 15. And why are there two variables for the same thing? MythicalShade 420 — 5y
0
game.Workspace. act.OnServerEvent:Connect(function(player) get rid of the L variable and change plr variable to player.Character stinkyest11 78 — 5y
1
also you spelt studio horrifically wrong in the title mate stinkyest11 78 — 5y

1 answer

Log in to vote
0
Answered by
Pojoto 329 Moderation Voter
5 years ago

One thing you tried to do was get the LocalPlayer in a server script. This can't be done because the server has no idea what LocalPlayer is. It sees all the players and won't be able to find a single one if you don't define a single player.

The way you can tell which player fired the Remote Event is by adding a player parameter in OnServerEvent.

game.Workspace.fer.OnServerEvent:Connect(function()

In this section, you can change the script to:

game.Workspace.fer.OnServerEvent:Connect(function(plr)

And now you can use plr as a variable which stores the player who fired the remote event. Now you don't need to use LocalPlayer or Fire. Both of those don't even work anyways.

Ad

Answer this question