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

I have a script of a web shooter but it only works in studio, why?

Asked by 5 years ago

I have a script which works in studio but the problem is.. is wont work in game. The thing is in the game it shows the rope when I shoot it but I get stuck and I cant move.. in studio that doesnt happens and I can swing.

Any help please?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera

--/// Services
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local UIS = game:GetService('UserInputService')
local RunService = game:GetService('RunService')

--/// Main
local Humanoid = Character:FindFirstChild('Humanoid')
if Humanoid then
    Humanoid.JumpPower = 100
    Humanoid.WalkSpeed = 20
end

local Clicked = false
Mouse.Button1Down:Connect(function()
    if Clicked == false and Mouse.Target ~= nil and Character:FindFirstChild('LeftHand') then
        Clicked = true
        local Pos = Mouse.Hit.p


        if Character:FindFirstChild('HumanoidRootPart') then
            local Sound = Instance.new('Sound',Character.HumanoidRootPart)
            Sound.SoundId = 'rbxassetid://273574119' 
            Sound:Play()
        end

        Part = Instance.new('Part',workspace)
        Part.Size = Vector3.new(1,1,1)
        Part.Transparency = 1
        Part.Anchored = true
        Part.CanCollide = false
        Part.CFrame = CFrame.new(Pos)

        local Att0 = Instance.new('Attachment',Player.Character.RightHand)
        local Att1 = Instance.new('Attachment',Part)

        Rope = Instance.new('RopeConstraint',Player.Character.RightHand)
        Rope.Color = BrickColor.new('Institutional white')
        Rope.Visible = true
        Rope.Length = (Player.Character.LeftHand.Position - Part.Position).magnitude
        Rope.Attachment0 = Att0
        Rope.Attachment1 = Att1

        --// Force
        Force = Instance.new('BodyForce',Player.Character:WaitForChild('HumanoidRootPart'))
        while Force ~= nil and wait() do
            Force.Force = Camera.CFrame.lookVector * Vector3.new(100,0,100) --Force
        end    
    elseif Clicked == true then
        Clicked = false

        if Rope then
            Rope:Destroy()
        end
        if Part then
            Part:Destroy()
        end
        if Force then
            Force:Destroy()
        end
    end
end)

--/// Climbing Web
UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Q then
        ClimbingWeb = false
        if Rope then
            ClimbingWeb = true
            while ClimbingWeb and Rope do
                Rope.Length = Rope.Length - 2 --PullPower
                RunService.RenderStepped:Wait()
            end
        end
    end
end)

UIS.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Q then
        ClimbingWeb = false
    end
end)

--/// ReleaseWeb
UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E then
        ReleaseWeb = false
        if Rope then
            ReleaseWeb = true
            while ReleaseWeb and Rope do
                Rope.Length = Rope.Length + 2 -- ReleasePower
                RunService.RenderStepped:Wait()
            end
        end
    end
end)

UIS.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E then
        ReleaseWeb = false
    end
end)

This works in studio but in-game I get stuck when I click the mouse to shoot the rope constraint

0
What script type is it? User#19524 175 — 5y
0
Any in-game errors? AIphanium 124 — 5y
0
@incapaz Its a LocalScript inside StarterPack. @Alphanium Nope, the rope works, I hear the sound but get stuck and unable to move, unlike in studio where I can swing. HeyItzDanniee 252 — 5y
1
Probably an FE problem, not really sure . Next_Byte 21 — 5y
0
Next_Byte is most likely correct, it's a FE problem. The client alone can't do what you're trying to do now that FE is always on/mandatory. You would have to use remote-events and change up your script a bit. RibgyTheRacoon 67 — 5y

Answer this question