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

Jurassic World Volcano Challenge Event (LavaDamage Script Not Working?)

Asked by 2 years ago
Edited 2 years ago

Hello does anyone know how to fix the lavadamage script from the Jurassic World Volcano Challenge event ages ago curious as wanna re-open the game with new updates (just to be clear this script is from Jurassic World Volcano Challenge event ages ago)

Edit: it work in studios but not in game confused

forgot to say this script is in ( ServerScriptService )

-- Amount of damage players will take when standing in lava
local LAVA_DPS = 300

-- Roblox Services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- Tables to keep track of which characters are on fire
local charactersOnFire = {}
local signalBindings = {}

-- Create and configure the fire
local function createFire()
    local fire = Instance.new("Fire")
    fire.Enabled = false
    fire.Size = 10
    return fire
end

-- Called when a new character model is created
local function onCharacterAdded(character)
    local humanoid = character:WaitForChild("Humanoid")
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local floorChangedSignal = humanoid:GetPropertyChangedSignal("FloorMaterial")

    -- Create fire effect to show the player if they are taking damage
    local fire = createFire()
    fire.Parent = humanoidRootPart

    -- Connects function to when the floor under the character changes
    signalBindings[character] = floorChangedSignal:Connect(function()
        -- If the character is standing on lava, add them to the list of on fire
        -- characters and turn on the fire effect. Otherwise to the opposite
        if humanoid.FloorMaterial == Enum.Material.CrackedLava then
            charactersOnFire[character] = true
            fire.Enabled = true
        else
            charactersOnFire[character] = nil
            fire.Enabled = false
        end
    end)
end

-- Clean up the event connections when a character model is removed
local function onCharacterRemoving(character)
    if signalBindings[character] then
        signalBindings[character]:Disconnect()
    end
    if charactersOnFire[character] then
        charactersOnFire[character] = nil
    end
end

-- Set up character event binding when player joins the game
local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
    player.CharacterRemoving:Connect(onCharacterRemoving)
end

-- Game update loop
local function onHeartbeat(delta)
    local damage = LAVA_DPS * delta

    -- Go through all of the characters on fire and make them take damage
    for character in pairs(charactersOnFire) do
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        if humanoid then
            humanoid:TakeDamage(damage)
        end
    end
end

-- Connect functions to events
Players.PlayerAdded:Connect(onPlayerAdded)
RunService.Heartbeat:Connect(onHeartbeat)
0
i read it and i dont see whats wrong with it. Im going to try this script in studio and see what happens ingame. AlexanderYar 788 — 2y
0
it work in studios but not in game confused to why it's not working but thanks for letting me know you don't see anythink wrong with it as that's good to know ProPopGamer 12 — 2y
0
Alright It also doesnt work ingame for me. Im gonna look at this some more and see if i can fix it. AlexanderYar 788 — 2y
0
Thank you so much AlexanderYar just hoping it can be fixed as wanna re-open the game with new updates just that one script that doesn't work sadly but thank you so much it really does mean alot to me that you're gonna see if you can fix it so thank you. ProPopGamer 12 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Alright so two things. Ill give you solution and suggestions on how to rewrite your code to improve it. Alright so first, adding the characters to the table to be checked. The way you do it is more likely to cause errors. The thing is i dont exactly know what those logic errors are, but i wouldnt add characters to a table the way you are doing it, in the first place. And all my adding-character-to-table scripts work fine. SO here is my way and a better way to do it.

local charTable = {}

table.insert(charTable, char) -- adds character
table.remove(charTable , table.find(charTable , character)) -- removes character

-- this is an example of how to go through each one in for loop
for key, value in pairs(charactersOnFire) do
    -- character is the value instead of the key. This could be the only problem, but im just giving you a better way to rewrite everything.
end

Instead of making character = true in the table (which is basically the same as the following but with extra steps), just add and remove the character completely from the table. This is the most simple way to do it and it is far less likely to cause errors. When coding, please try doing the most simple things so as to reduce the chance of logic errors and other errors.

Second, humanoid:GetPropertyChangedSignal"FloorMateral" for some reason only fires twice upon joining. And after that it does not work. But constantly printing the humanoid's floormaterial showed me it did still work and i could see when i was on cracked lava but it still didnt fire propertychanged signal thing. After a lot of research I have three solutions that are kind of hacky, but thats often the case with roblox since roblox is garbage.

1) Use a remotevent. Detect the floormaterial on the client side and then send it using remoteevent. And then take action on serverside. Dont worry about exploiters stopping the remote event from functioning, because if an exploiter can do that, they might as well use flying or any other technique to stop themselves from walking on lava so it doesnt matter anyway. I tried the proeprtychanged signal thing and it works CLIENT SIDE but not SEVER SIDE. It just doesnt seem to trigger propertychange signal server side even though the floor material does change server side. No clue why.

2) since you can read the humanoids floormaterial, you can constantly check it with while true do loop. Again, getpropetychanged signal just isnt being fired serverside.

3) Maybe you could try using another function?

Read this maybe it tells you WHY it doesnt trigger propertychangedsignal of humanoids floormaterial serve side : https://create.roblox.com/docs/reference/engine/classes/Humanoid#FloorMaterial

Im stumped so this is all imma do. Hope this helps. I was surprised it didnt work, getpropertychanged signal on humanoids floormaterial server side.

Edit: I checked the link that i said might explain why it doesnt fire and i think i know why now. It says FloorMaterial is NOT REPLICATED. Which i believe means it doesnt replicate it from client to server side. So I think FloorMaterial is only meant to be used on client side. So if you really want to check what material humanoid is standing on from SERVER SIDE, try using raycast or something.

Second edit: THE ANSWER IS RAYCAST. Floormaterial is apparently just a raycast downwards client side. So you can do the same on the server.

0
thank you also the script is from an old event ages ago so it could of just broke as i joined others who have the event map and the lava script doesn't work for them either ProPopGamer 12 — 2y
0
I see. Also heres a link that says some more. https://devforum.roblox.com/t/expensive-raycast-humanoidfloormaterial-emulation/580885. Apparently the raycast is the right way to do it since thats what floormaterial does anyway. Textual evidence: "FloorMaterial is, in fact, a downward raycast from the HumanoidRootPart.". so yeah i really think floor material is only meant to be used client side. AlexanderYar 788 — 2y
0
thank youso much for all you're help really does mean alot imma do some research on raycasting as new to scripting i can script small stuff but this looks big lol ProPopGamer 12 — 2y
0
Thanks. If you believe this is the best answer youre gonna get, please mark it as correct answer. AlexanderYar 788 — 2y
Ad

Answer this question