#Problem with a gravity script

78 messages · Page 1 of 1 (latest)

opal tundra
#

Can you show me the script

lucid blaze
#

yes

#

local part = script.Parent
part.Touched:Connect(function(touchPart)
local Humanoid = touchPart.Parent:FindFirstChild("Humanoid")
if Humanoid then
part.CanCollide = false
game.Workspace.Gravity = 50
end
end)

left bough
lucid blaze
lucid blaze
left bough
#

server runs for everything

left bough
lucid blaze
left bough
#

alr

#

on all the parts is cantouch = true?

lucid blaze
#

yes

#

the gravity change works but for all players when one player touch the part

left bough
#

try doing .workspace

#

im pretty sure ther eis a difference

lucid blaze
left bough
#

lowercase

#

or workspace.

lucid blaze
#

local character = script.Parent
local hrp = character:WaitForChild("HumanoidRootPart")

hrp.Touched:Connect(function(hit)
if hit.Name == "PartGravityOne" then
game.Workspace.Gravity = 192.2

if hit.Name == "PartGravityTwo" then
    game.Workspace.Gravity = 50

if hit.Name == "PartGravityThree" then
    game.Workspace.Gravity = 192.2

if hit.Name == "PartGravityFour" then
    game.Workspace.Gravity = 300

end
end
end
end
end)

#

where in the script?

left bough
#

replace game.Workspace to workspace

lucid blaze
#

oh right , now no errors in the code

#

i mean , no error but maybe the code doesn't work , i have to test it. thank you for the help if it doesn't work can i ask you again?

left bough
#

sure

#

only reason i suggest that is i know there is a difference between workspace and game.Workspace

lucid blaze
#

Can I ask you a favor if you want?
i need another player for the test would you like to enter my game for a couple of minutes?

left bough
#

you can test it in studio

#

there is a test tab at the top

#

and a thingy that loads two players that you can control

#

search around for a second you will find it

lucid blaze
#

i see

#

now i try

#

thank you for the hint

#

omg 2 players hahahah

lucid blaze
tepid raftBOT
#

studio** You are now Level 4! **studio

left bough
#

under each if hit.name == blahblah put print("touched")

#

open output

#

and try agian

lucid blaze
#

okay

lucid blaze
left bough
#

wait so its changing the gravity just on every player?

left bough
#

weird

lucid blaze
#

it works , it changes gravity but for all

left bough
#

send me your current script

lucid blaze
#

local character = script.Parent
local hrp = character:WaitForChild("HumanoidRootPart")

hrp.Touched:Connect(function(hit)
if hit.Name == "PartGravityOne" then
workspace.Gravity = 192.2

if hit.Name == "PartGravityTwo" then
    workspace.Gravity = 50

if hit.Name == "PartGravityThree" then
    workspace.Gravity = 192.2

if hit.Name == "PartGravityFour" then
    workspace.Gravity = 300

end
end
end
end
end)

#

this is inside the startercharacterscripts in a local script

left bough
#

hmmm

#

try putting it in starter player scripts

#

and instead of local character = script.Parent

#

do

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
lucid blaze
left bough
lucid blaze
#

'''lua local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character

local hrp = Players:WaitForChild("HumanoidRootPart")

hrp.Touched:Connect(function(hit)
if hit.Name == "PartGravityOne" then
workspace.Gravity = 192.2

if hit.Name == "PartGravityTwo" then
    workspace.Gravity = 50

if hit.Name == "PartGravityThree" then
    workspace.Gravity = 192.2

if hit.Name == "PartGravityFour" then
    workspace.Gravity = 300

end
end
end
end
end) '''

#

ehm

left bough
#

`` not "

lucid blaze
#

i don't have these `` so i copy it

left bough
#

kk

lucid blaze
#

local Player = Players.LocalPlayer
local Character = Player.Character 

local hrp = Players:WaitForChild("HumanoidRootPart")

hrp.Touched:Connect(function(hit)
    if hit.Name == "PartGravityOne"  then
        workspace.Gravity = 192.2

    if hit.Name == "PartGravityTwo" then
        workspace.Gravity = 50

    if hit.Name == "PartGravityThree" then
        workspace.Gravity = 192.2

    if hit.Name == "PartGravityFour" then
        workspace.Gravity = 300
end
end
end
end
end)```
#

so this is the script

left bough
#

i think i had a script like this that actually worked

#

lemme get on the right account and nab it

#

ill try and find it

lucid blaze
#

ok thx

left bough
#

couldnt find it mustve been lost to time

#

i can help you tommorow but its 4 in the morning for me

#

sorry

lucid blaze
#

no problem

left bough
#

alr hopefully we solve it eventually

lucid blaze
#

yes , when you can and want just dm me

#

see you

left bough
#
-- Services
local Players = game:GetService("Players")

-- Player Vars
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

-- Funcs
local function GetPart(Hit)
    if Hit.Name == "PartGravityOne" then
        workspace.Gravity = 192.2
    elseif Hit.Name == "PartGravityTwo" then
        workspace.Gravity = 50
    elseif Hit.Name == "PartGravityThree" then
        workspace.Gravity = 192.2
    elseif Hit.Name == "PartGravityFour" then
        workspace.Gravity = 300
    end
end

-- Loops
for Number, Descendent in pairs(Character:GetDescendants()) do
    if Descendent:IsA("Part") or Descendent:IsA("MeshPart") then
        Descendent.Touched:Connect(function(Hit)
            GetPart(Hit)
        end)
    end
end

got a working script here, put it in starter character scripts

#

@lucid blaze

left bough
#

and yes i did test it on two playes and it works perfectly